﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Hostal.Bussines.Entities;
using Hostal.Bussines.Logic;
using Hostal.Bussines.Logic.Service;
using Microsoft.Practices.Unity;

namespace Hostal.MVC.Controllers
{
    public class HuespedController : Controller
    {
        [Dependency]
        public IHuespedService huespedService { set; get; }
        //
        // GET: /Huesped/

        public ActionResult Index()
        {
            var lista = huespedService.GetAllFromHuesped();
            return View(lista);
        }

        [HttpPost]
        public ActionResult Index(string dni = "")
        {
            var lista = huespedService.GetFromHuespedByDni(dni);
            return View(lista);
        }

        public ActionResult Create()
        {
            var huesped = new Huesped();
            return View(huesped);
        }

        [HttpPost]
        public ActionResult Create(Huesped huesped)
        {
            huespedService.AddHuesped(huesped);
            return RedirectToAction("Index");
        }

        public ActionResult Edit(Int32 id)
        {
            var huesped = huespedService.GetFromHuespedById(id);
            return View(huesped);
        }

        [HttpPost]
        public ActionResult Edit(Huesped huesped)
        {
            huespedService.UpdateHuesped(huesped);
            return RedirectToAction("Index");
        }

        public ActionResult Delete(Int32 id)
        {
            huespedService.RemoveHuesped(id);
            return RedirectToAction("Index");
        }

    






    }
}
